namespace GemBox.Spreadsheet
{
    using System;

    internal class ArrayFormulaToken : FormulaToken
    {
        private byte columnsAmount;
        private ushort rowsAmount;

        public ArrayFormulaToken(FormulaTokenCode code) : base(code, 8, FormulaTokenType.Operand)
        {
        }

        public override byte[] ConvertToBytes()
        {
            byte[] buffer = base.ConvertToBytes();
            buffer[1] = 0;
            return buffer;
        }

        public override void Read(byte[] rpnBytes, int startIndex)
        {
            this.columnsAmount = rpnBytes[startIndex];
            this.rowsAmount = BitConverter.ToUInt16(rpnBytes, startIndex + 1);
        }

        public override string ToString()
        {
            return string.Empty;
        }

        public byte ColumnsAmount
        {
            get
            {
                return this.columnsAmount;
            }
        }

        public ushort RowsAmount
        {
            get
            {
                return this.rowsAmount;
            }
        }
    }
}
